package com.yan.controller;


import com.yan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;


@Controller
public class HelloController {

    @Autowired
    private UserService userService;

    @RequestMapping("/hello")
    public String sayHello(HttpServletRequest request){

        try {
            request.setAttribute("user", userService.getUserById(1).getName());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "hello";
    }

}
